Skip to content

BUG: Raise ValueError for non-string columns in read_json orient='table' (GH19129) #61359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

amoitra1
Copy link

@amoitra1 amoitra1 commented Apr 26, 2025

Looking forward to feedback. Thanks!

@amoitra1
Copy link
Author

pre-commit.ci autofix

@@ -372,6 +372,11 @@ def parse_table_schema(json, precise_float: bool) -> DataFrame:
pandas.read_json
"""
table = ujson_loads(json, precise_float=precise_float)
fields = table["schema"]["fields"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace other instances of table["schema"]["fields"] below with fields?

@@ -372,6 +372,11 @@ def parse_table_schema(json, precise_float: bool) -> DataFrame:
pandas.read_json
"""
table = ujson_loads(json, precise_float=precise_float)
fields = table["schema"]["fields"]

if any(not isinstance(field["name"], str) for field in fields):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if any(not isinstance(field["name"], str) for field in fields):
if not all(isinstance(field["name"], str) for field in fields):

NIt: IMO this reads a little clearer with me

@mroeschke mroeschke added Error Reporting Incorrect or improved errors from pandas IO JSON read_json, to_json, json_normalize labels Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise ValueError for read_json and orient='table' With Numeric Column Names
2 participants